package com.xpalive.index.controller;

import com.xpalive.base.dto.result.RespResult;
import com.xpalive.index.dto.Index;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/index")
@Slf4j
@AllArgsConstructor
public class IndexController {

    @GetMapping("/exec")
    public RespResult<String> exec(@RequestHeader String tenant) {
        log.info(tenant);
        return RespResult.ofSuccess(tenant);
    }

    @PostMapping("/exec")
    public RespResult<Object> exec(@RequestHeader HttpHeaders tenant, @RequestBody Index index) {
        //https://www.jianshu.com/p/bf59fbf5ccce
        log.info(tenant.get("tenant").toString());
        log.info(index.toString());
        return RespResult.ofSuccess();
    }
}
